#ifndef APPLICATION_H
#define APPLICATION_H

#include <QList>
#include <QObject>
#include <graphicview.h>
#include <scene.h>

#include "global.h"

class ApplicationsManager;
class ZonesManager;
class TasksManager;
class GetOpt;
class QTcpServer;
class ExpandingWindow;
class ServerTask;
class TcpServer;

O_PRIVATE_DECLARE(Application);
class Application : public QObject
{
Q_OBJECT
public:
    Application(int argc, char **argv);
    ~Application();
    void setupDesktops();
    void setupViews();

    Scene* primaryScene();
    GraphicView* primaryView();

    void connectToZone(const QString& name, const char * slot, const QObject * sender, const char * signal, Qt::ConnectionType type = Qt::AutoConnection);
    ExpandingWindow* createToolbar(QWidget* parent, int type);

    void initialize();
    void uninitialize();

    ZonesManager* zones()const;
    TasksManager* tasks()const;
signals:

    void menuStateChange();
    void menuRestore();

public slots:
    void handleMessage(const QString& message);
    void showMenu();
    void updateView();


    void menuClicked(const QString& data);
    void showPreview(const QString& data);
    void hidePreview(const QString& data);

    void toolbarClick();

    void toogleFullScreen();
    void showOptra();
    void hideOptra();

protected:
    void keyPressEvent (QKeyEvent * event);
    bool event (QEvent * e);

private:
    void addView(Optra::ZoneWindow * view);
    void addTool(Optra::ZoneWindow * tool);
    void addMenu(QMenu* menu);

    void createMenu();
    void createPreview();
    void checkCommandLine(GetOpt* line, bool init);

    friend class ProxyImpl;
    friend class OptraZone;
    friend class Shell;
    friend class TcpServer;

    O_PRIVATE_DECLARE_MEMBER(Application)

};

#endif // APPLICATION_H
